<template>
	<view>
		<view class="plr40 content">
		<!-- 	<view class="">
				<image src="`${$domain.ossapi}logo.png`" mode="" style="width: 140upx;height: 140upx;"></image>
			</view> -->
			<!-- <view class="ft20 mt20">欢迎使用</view>
			<view class="ft24 mt10 bold">岐黄客 - 医生端</view>
			<view class="mt50">
				<view class="bgInput radius10 plr20">
					<input type="text" v-model="form.username" class="h55" placeholder="请输入账号" placeholder-class="placeholderStyle" />
				</view>
				<view class="bgInput radius10 plr20 mt20">
					<input type="text" v-model="form.password" class="h55" placeholder="请输入密码" placeholder-class="placeholderStyle" />
				</view>
			</view>
			<view class="mt20 align-center justify-between">
				<view class="light" @click="navTo('sign')">注册新账号</view>
				<view class="" @click="navTo('forgetPwd')">忘记密码？</view>
			</view> -->
			<!-- <button class="" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" >微信授权登录</button> -->
            
			<button class="submit" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"    >手机号快捷登录</button>
			

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
					form:{
						account:'13938586846',
						password:'123456'
					},
                    sessionKey:""
			}
		},
        onLoad() {
          this.getSessionKey()  
        },
		methods: {
            async getSessionKey(){
                let vm =this
                let result = await uni.login()
                
                 this.$api.wechatSession({
                     code: result[1].code,
                     autoLogin: true
                 }).then(res=>{
                     vm.sessionKey = res.data.session_id
                     uni.setStorageSync('sessionKey', res.data.session_id)
                    console.log(res)
                })
            },
            getPhoneNumber(event){
                    let vm =this
                    this.$api.wechatLogin({
                        event:'login',
                       code: event.detail.code,
                       iv: event.detail.iv,
                       encryptedData: event.detail.encryptedData,
                       session_id:vm.sessionKey|| uni.getStorageSync("session_id"), 
                    }).then(res=>{
                        console.log(res)
                            if(res.code==1){
                                this.$utils.msg(res.msg)
                                uni.setStorageSync('logintoken', res.data.token)
                                setTimeout(()=>{
                                    uni.reLaunch({
                                        url:'/pages/tabbar/index'
                                    })
                                },800)
                            }
                    })
            },
          
			
			

		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}

	.content {
		padding-top: 150upx;
	}
    .submit{
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            max-width: 690rpx;
            height: 96rpx;
            margin: 0 auto;
            font-size: 30rpx;
            color: #fff;
            border-radius: 30rpx;
            background: #548999;
            position: relative;
    }
</style>